/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 鸭子模拟器
 * @Description *
 * @Package designmodel.composite.simulator
 * @date 2021/3/2 4:21 下午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package designmodel.composite.simulator;

import designmodel.composite.Goose;
import designmodel.composite.Quackable;
import designmodel.composite.adaptor.GooseAdapter;
import designmodel.composite.factory.AbstractDuckFactory;
import designmodel.composite.factory.WrapperDuckFactory;
import designmodel.composite.wrapper.QuackWrapper;

public class DuckSimulator {

    public static void main(String[] args) {

        AbstractDuckFactory duckFactory = new WrapperDuckFactory();
        DuckSimulator duckSimulator = new DuckSimulator();
        duckSimulator.simulate(duckFactory);
    }

    void simulate(AbstractDuckFactory duckFactory) {

        Quackable mallardDuck = duckFactory.createMallardDuck();
        Quackable redheadDuck = duckFactory.createRedheadDuck();
        Quackable duckCall = duckFactory.createDuckdCall();
        Quackable rubberDuck = duckFactory.createRubberDuck();

        Quackable goose = new GooseAdapter(new Goose());

        System.out.println("鸭子模拟器启动");



        simulate(mallardDuck);
        simulate(redheadDuck);
        simulate(duckCall);
        simulate(rubberDuck);
        simulate(goose);

        System.out.println("鸭子叫了总共：" + QuackWrapper.getQuacks() + " 次");
    }

    void simulate(Quackable duck) {
        duck.quack();
    }
}
